package com.hsp.homework.homework10;

import java.util.Objects;

public class Doctor {
    private String name,job,gender;
    private int age;
    private double sal;

    public Doctor(String name, String job, String gender, int age, double sal) {
        this.name = name;
        this.job = job;
        this.gender = gender;
        this.age = age;
        this.sal = sal;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getSal() {
        return sal;
    }

    public void setSal(double sal) {
        this.sal = sal;
    }

    @Override
    public boolean equals(Object obj){
        if(this == obj){return true;}
        if(!(obj instanceof Doctor)){return  false;}
//        return this.equals(obj)?true:false;
        //向下转型，因为obj的运行类型是Doctor或者其子类型
        Doctor doctor = (Doctor) obj;
        return age == doctor.age && Double.compare(doctor.sal, sal) == 0 && Objects.equals(name, doctor.name) && Objects.equals(job, doctor.job) && Objects.equals(gender, doctor.gender);
    }


//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Doctor doctor = (Doctor) o;
//        return age == doctor.age && Double.compare(doctor.sal, sal) == 0 && Objects.equals(name, doctor.name) && Objects.equals(job, doctor.job) && Objects.equals(gender, doctor.gender);
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(name, job, gender, age, sal);
//    }
}
